﻿function BackFunc(CustIndex) {
    UpdateUrl = Portal.Vision.UpdateCustomer.GetViewUrl(CustIndex).value;
    window.open(UpdateUrl, "_self");
}

function SaveCustomer(CustIndex) {
    CustName = document.getElementById("divCustName").value;
    Address = document.getElementById("divAddress").value;
    Phone = document.getElementById("divPhone").value;
    Fax = document.getElementById("divFax").value;
    Email = document.getElementById("divEmail").value;
    CountryIndex = document.getElementById("divCountryIndex").value;

    bGe = document.getElementById("divCheckGe").checked.toString();
    bLegal = document.getElementById("divCheckLegal").checked.toString();
    bProject = document.getElementById("divCheckProject").checked.toString();
    bIP = document.getElementById("divCheckIP").checked.toString();

    bAgency = document.getElementById("divCheckAgency").checked.toString();
    bApplicant = document.getElementById("divCheckApplicant").checked.toString();
    bClient = document.getElementById("divCheckClient").checked.toString();
    bThirdParty = document.getElementById("divCheckThirdParty").checked.toString();

    CustMemo = document.getElementById("divCustMemo").value;
    ShortName = document.getElementById("divShortName").value;
    CustomerTypeIndex = document.getElementById("divCustomerTypeIndex").value;
    Discount = document.getElementById("divDiscount").value;
    RelationCode = document.getElementById("txtRelationCode").value;
    RelationNote = document.getElementById("txtRelationNote").value;

    RetValue = Portal.Vision.UpdateCustomer.ServerSideSaveCustomer(CustIndex.toString(), CustName, Address, Phone, Fax, Email, bGe, bLegal, bProject, bIP, bAgency, bApplicant, bThirdParty, bClient, CustMemo, CountryIndex, ShortName, Discount, CustomerTypeIndex, RelationCode, RelationNote).value;
    if (RetValue.indexOf("ERROR") > -1) {
        alert(RetValue);
        return;
    }
    alert("Khách hàng đã được cập nhật thành công!");
    UpdateUrl = Portal.Vision.UpdateCustomer.GetViewUrl(CustIndex.toString()).value;
    window.open(UpdateUrl, "_self");
}